"""
@File         : models.py
@Time         : 2024/05/06 15:52:15
@Author       : Qrj
@Email        : 923207736@qq.com
@Description  : 通知公告相关数据模型
"""

from datetime import datetime

from sqlalchemy import BigInteger, Boolean, Column, DateTime, Integer, String, Text

from src.models.models import OrmBase

from .enums import NoticeTypeEnum


class Notice(OrmBase):
    """角色数据模型"""

    __tablename__ = "system_notice"

    id = Column(BigInteger(), primary_key=True, autoincrement=True, comment="主键")
    title = Column(String(50), nullable=False, comment="公告标题")
    content = Column(Text(), nullable=False, comment="公告内容")
    notice_type = Column(
        String(20),
        default=NoticeTypeEnum.background_notice.value,
        nullable=False,
        comment="通知公告类型",
    )
    status = Column(
        Boolean(), default=True, nullable=False, comment="状态"
    )  # (True正常 False停用)
    show_order = Column(
        Integer(), nullable=False, index=True, default=1, comment="显示顺序"
    )
    expiration_datetime = Column(
        DateTime(), nullable=False, index=True, comment="过期时间"
    )
    create_datetime = Column(
        DateTime(), nullable=False, default=datetime.now, index=True, comment="创建时间"
    )
    update_datetime = Column(
        DateTime(),
        nullable=False,
        default=datetime.now,
        onupdate=datetime.now,
        index=True,
        comment="修改时间",
    )
    # 创建者用户名
    creator_username = Column(
        String(20), default="", nullable=False, comment="创建者用户名"
    )
    # 修改者用户名
    updater_username = Column(
        String(20), default="", nullable=False, comment="修改者用户名"
    )
    # 租户ID(级联删除)
    tenant_id = Column(BigInteger(), nullable=False, index=True, comment="租户ID")
